<script setup lang="ts">
import { Button as VanButton } from 'vant'
import { useUserStore } from './stores'
import { request } from '@/utils/request'
import type { User } from '@/types/user'
const store = useUserStore()

// 测试 调用个人信息接口
const getUserInfo = async () => {
  const res = await request('/patient/myUser')
  console.log(res)
}
// 测试响应拦截器
const login = async () => {
  const res = await request<User>('/login/password', 'POST', {
    mobile: '13211112222',
    password: 'abc12'
  })
  store.setUser(res.data)
}
</script>

<template>
  <div class="app-page">
    app
    <VanButton type="primary">按钮1</VanButton>
    <van-button>按钮2</van-button>
    <a href="">测试css变量</a>
    <div>
      {{ store.user?.account }}
    </div>
    <van-button
      @click="
        store.setUser({
          token: '1234',
          id: '111111',
          account: '老韩',
          mobile: '13122223333',
          avatar: 'sadfdsafasdf'
        })
      "
      >设置</van-button
    >
    <van-button @click="store.delUser()">登出</van-button>
    <van-button @click="getUserInfo">获取个人信息</van-button>
    <van-button @click="login">登录</van-button>
  </div>
</template>
<!-- 定义css变量 用 --变量名     使用css变量用    var(变量名) -->
<style lang="scss"></style>
